<?php
$dep_id=$data['dep_id'];
$doc_id=$data['doc_id'];
$app_date= $data['app_date'];
$app_time= $data['app_time'];
//$datalist=array();
require_once './connect.php';
//处理数据
/*$sql = "SELECT dep_id FROM _department where dep_name='$_dep'";
$result = $conn->query($sql);
if($result->num_rows)
{
    $row=$result->fetch_assoc();
    $_dep=$row['dep_id'];

}
$sql = "SELECT doc_id FROM _doctor where doc_name='$_doc'";
$result = $conn->query($sql);
if($result->num_rows)
{
    $row=$result->fetch_assoc();
    $_doc=$row['doc_id'];

}*/
if($app_time=='morning')
{
    $app_time=0;
    $app_max=16;
}else if($app_time=='afternoon')
{
    $app_time=1;
    $app_max=14;
}


//添加语句
$sql = "INSERT INTO _appoint(doc_id,dep_id,app_date,app_time,app_max)VALUES ('$doc_id','$dep_id','$app_date','$app_time','$app_max')";
if ($conn->query($sql) === TRUE) {
    $response=array(
        'resultCode'=>'0',
        'resultMsg'=>'成功'
    );
} else {
    $response=array(
        'resultCode'=>'0',
        'resultMsg'=>'失败'
    );
}

//echo 'test';
echo json_encode($response);
$conn->close();
?>